from django import template
from Blogs.models import Blog,Tag,UserIP

register = template.Library()

@register.simple_tag
def get_visits(blog):
	count=0
	for uip in blog.userip_set.all():
		count=count+uip.count
	return count

@register.simple_tag
def tagblock(tag):
	return '<div class="tag" style="background:{}">{}</div>'.format(tag.color,tag.name)
	
tagblock.is_safe=True	